home *** CD-ROM | disk | FTP | other *** search
- ' PRINTF.BAS
- ' by Ronnie Weiss
- '
- ' public domain
- ' No warranties or guarantees are expressed or implied.
- '
- 'Does color, locate and printing in one command. Switches can be put
- 'anywhere in the parameter (string). You must leave a space in between
- 'all switches.
- '
- 'Switches are as follows:
- '
- '/n - skips to the beginning of the next line
- '// - prints a /
- '/f - followed by the forground color, changes text color
- '/b - followed by the background color, changes background color
- '/r - followed by the y coordinate changes the y cursor position
- '/c - followed by the x coordinate changes the x cursor position
-
- DECLARE SUB printf (txt$)
-
- printf "/f12 /r3 /c23 Hello"
-
- SUB printf (txt$)
- x% = 1
- DO
- attr% = CINT(VAL(MID$(txt$, x% + 2, 2))) 'convert numbers in
- SELECT CASE LCASE$(MID$(txt$, x%, 2)) 'the text to integers
- CASE "/f"
- COLOR attr%
- IF attr% > 9 THEN
- x% = x% + 4
- ELSE
- x% = x% + 3
- END IF
- CASE "/b"
- COLOR , attr%
- IF attr% > 9 THEN
- x% = x% + 4
- ELSE
- x% = x% + 3
- END IF
- CASE "/n"
- PRINT
- x% = x% + 2
- CASE "/r"
- LOCATE attr%
- IF attr% > 9 THEN
- x% = x% + 4
- ELSE
- x% = x% + 3
- END IF
- CASE "/c"
- LOCATE , attr%
- IF attr% > 9 THEN
- x% = x% + 4
- ELSE
- x% = x% + 3
- END IF
- CASE "//"
- PRINT "/";
- x% = x% + 2
- END SELECT
- PRINT MID$(txt$, x%, 1); 'Print the text
- x% = x% + 1
- LOOP UNTIL LEN(txt$) < x%
- END SUB
-
-